<html>
<meta charset="utf-8">
<?php
header("Content-Type: text/html;charset=utf-8"); 
include "mysql.php";
$aa=new mysql;
$aa->link("mysql");

//创建数据库
$query="CREATE DATABASE `smallT`";
if ($aa->excu($query)){
    echo "===数据库创建成功！===";
    }
$aa->link("smallT");

//////////创建数据表product_class/////////////
$query="CREATE TABLE `product_class` (
  `id` int(11)  NOT NULL primary key  auto_increment,
  `class_name` varchar(66) default NULL,
  `show_order` int(11) default '0',
  UNIQUE KEY `id` (`id`)
) ";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;数据表-product_class-创建成功！";

//////////创建数据表product_info/////////////
$query="CREATE TABLE `product_info` (
  `id` int(11) NOT NULL auto_increment primary key,
  `class_id` int(11) default '0',
  `name` varchar(88) NOT NULL,
  `intro` text NOT NULL,
  `imgsrc` varchar(888) NOT NULL,
  `show_order` int(11) default '0',
  `price` int(11) default '0',
  UNIQUE KEY `id` (`id`)
)";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;数据表-product_info-创建成功！";


//////////创建数据表user_info/////////////
$query="CREATE TABLE `user_info` (
  `id` int(11) NOT NULL auto_increment primary key,
  `user_name` varchar(16) NOT NULL,
  `user_pw` varchar(16) NOT NULL,
  `tel` int(11) NOT NULL,
  `e-mail` varchar(88) NOT NULL,

  UNIQUE KEY `id` (`id`)
)";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;数据表-user_info-创建成功！";

//////////创建数据表manage_info/////////////
$query="CREATE TABLE `manage_info` (
  `id` int(11) NOT NULL auto_increment primary key,
  `user_name` varchar(16) NOT NULL,
  `user_pw` varchar(16) NOT NULL,

  UNIQUE KEY `id` (`id`)
)";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;数据表-manage_info-创建成功！";

//////////////////初始化数据//////////////////////////
echo "<br>===初始化基本数据===";

//////////////////初始化管理用户名和密码//////////////////////////
$query="INSERT INTO `manage_info` VALUES (1, 'admin', 'admin')";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;管理员用户名、密码初始成功";
echo "<br>&nbsp;&nbsp;&nbsp;用户名：admin";
echo "<br>&nbsp;&nbsp;&nbsp;密 码：admin";

//////////////////初始化测试父板块//////////////////////////
$query="INSERT INTO `product_class` (id, class_name, show_orger) 
            VALUES ('', 'phone', 1), VALUES ('', 'peijian', 3)";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;添加“productclass”成功！";

//////////////////初始化测试子板块//////////////////////////
$query="INSERT INTO `product_info` VALUES (1, 2, 'Smartisan S-100 半入耳式线控耳机', '卓越的 14.2mm 发音单元、三按键式线控', '', 1, 99);";
$aa->excu($query);
echo "<br>&nbsp;&nbsp;添加“productinfo”成功！";
?>
</html>